home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
clipper
/
nfsrc21.zip
/
DISPC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-11-18
|
28KB
|
934 lines
/*
* File......: DISPC.C
* Author....: Mike Taylor
* Date......: $Date: 18 Nov 1991 02:20:20 $
* Revision..: $Revision: 1.4 $
* Log file..: $Logfile: E:/nanfor/src/dispc.c_v $
*
* This is an original work by Mike Taylor and is placed in the
* public domain.
*
* Modification history:
* ---------------------
*
* $Log: E:/nanfor/src/dispc.c_v $
*
* Rev 1.4 18 Nov 1991 02:20:20 GLENN
* Mike fixed a bug in _ft_dfinit() related to allocating memory. Some
* users had been reporting problems, but everyone who tested this patch
* reported success.
*
* Rev 1.3 17 Aug 1991 15:25:46 GLENN
* Don Caton fixed some spelling errors in the doc
*
* Rev 1.2 15 Aug 1991 23:08:14 GLENN
* Forest Belt proofread/edited/cleaned up doc
*
* Rev 1.1 14 Jun 1991 19:53:42 GLENN
* Minor edit to file header
*
* Rev 1.0 01 Apr 1991 01:02:46 GLENN
* Nanforum Toolkit
*
*
*/
#include "extend.h"
#include "dfkey.h"
#define MK_FP(seg, ofs) ((void far *) (((unsigned long)(seg) << 16) | (unsigned)(ofs)))
#define FP_SEG(fp) (*((unsigned *)&(fp) + 1)) // copied from MSC 5.1
#define FP_OFF(fp) (*((unsigned *)&(fp))) // include file 'dos.h'
#define OFF 0
#define ON (!OFF)
#define NO 0
#define YES (!NO)
#define OK 0
#define CR ((char) 13)
#define LF ((char) 10)
#define FEOF ((char) 26)
#define SEEK_END 2 // file seek directions
#define SEEK_CUR 1
#define SEEK_SET 0
#define READONLY 0 // open file modes
#define WRITEONLY 1
#define READWRITE 2
#define MDASEG 0x0b000 // mono video memory segment
#define CGASEG 0x0b800 // color video memory segment
#define BUFFERSIZE 4096 // maximum size of the file buffer
#define MAXLINE 255 // default maximum size of a line
long buffoffset; // offset into buffer of current line
long fsize; // file size in bytes
int bufftop, buffbot; // first and last character in buffer
int wintop, winbot; // first and last character in window
int winrow, wincol; // row and column of window highlight
int sline, eline; // start and end line of window
int scol, ecol; // start and end col of window
int height, width; // height and width of window
int infile; // input file handle
int maxlin; // line size
int buffsize; // buffer size
int hlight; // highlight attribute
int norm; // normal attribute
int kcount; // number of keys in terminate key list
int colinc; // col increment amount
int brows; // browse flag
char refresh; // YES means refresh screen
char kstr[25]; // terminate key string
char far *buffer; // file buffer pointer
char far *lbuff; // line buffer pointer
char far *vseg; // video segment variable
// prototypes
CLIPPER _ft_dfinit(void);
CLIPPER _ft_dfclos(void);
unsigned char keyin(void);
void chattr(int x, int y, int len, int attr);
long getblock(long offset);
void buff_align(void);
void win_align(void);
void disp_update(int offset);
void windown(void);
void winup(void);
void linedown(void);
void lineup(void);
void filetop(void);
void filebot(void);
// found in dispa.asm
int _ft_fileread(int handle, char far *buffer, int bytes);
long _ft_fileseek(int handle, long offset, int direction);
void _ft_gotoxy(int x, int y);
char _ft_getkey(void);
char far * _ft_vconfig(void);
// this is defined because I found out that CLIPPER has a version
// strcpy linked in normally - this just shut's up the LINT check
extern char *strcpy(char far *, char far *);
/*
* chattr() replace the color attribute with a new one starting at
* location x, y and going for length len.
*
*/
static void chattr(int x, int y, int len, int attr)
{
int i;
char far *vmem;
vmem = vseg;
FP_OFF(vmem) = (y * 160) + (x * 2) + 1; // calc the screen memory coord
for (i = 0; i <= len; i++, vmem += 2) // write the new attribute value
*vmem = (char) attr;
}
/*
* keyin() gets the next key typed and does any translation needed.
* Some keys are converted to a common name - like the up arrow is
* converted to the UP value which also is the Ctrl-E value. This
* allows the Wordstar-like control keys to be used. Only extended
* keys are translated - the values of the defines were chosen to
* match up with the non-extended key codes.
*
*/
static unsigned char keyin()
{
unsigned char ch;
ch = (unsigned char) _ft_getkey(); // get the next key
if ( ch == 0x00 ) // check to see if it's extended
{
ch = (unsigned char) _ft_getkey(); // if so, read the second part
switch ( ch ) // and convert it
{
case 75 : ch = LFT; break;
case 77 : ch = RGT; break;
case 72 : ch = UP; break;
case 80 : ch = DN; break;
case 71 : ch = HOME; break;
case 79 : ch = ENND; break;
case 73 : ch = PGUP; break;
case 81 : ch = PGDN; break;
case 62 : ch = F4; break;
case 117 : ch = CENND; break;
case 119 : ch = CHOME; break;
case 118 : ch = CPGDN; break;
case 132 : ch = CPGUP; break;
case 116 : ch = CRGT; break;
case 115 : ch = CLFT; break;
case 82 : ch = INS; break;
case 83 : ch = DEL; break;
case 68 : ch = F0; break;
case 59 : ch = F1; break;
case 60 : ch = F2; break;
case 61 : ch = F3; break;
case 63 : ch = F5; break;
case 64 : ch = F6; break;
case 65 : ch = F7; break;
case 66 : ch = F8; break;
case 67 : ch = F9; break;
case 113 : ch = AF0; break;
case 104 : ch = AF1; break;
case 105 : ch = AF2; break;
case 106 : ch = AF3; break;
case 107 : ch = AF4; break;
case 108 : ch = AF5; break;
case 109 : ch = AF6; break;
case 110 : ch = AF7; break;
case 111 : ch = AF8; break;
case 112 : ch = AF9; break;
case 94 : ch = CF1; break;
case 95 : ch = CF2; break;
case 96 : ch = CF3; break;
case 97 : ch = CF4; break;
case 98 : ch = CF5; break;
case 99 : ch = CF6; break;
case 100 : ch = CF7; break;
case 101 : ch = CF8; break;
case 102 : ch = CF9; break;
case 103 : ch = CF0; break;
case 120 : ch = ALT1; break;
case 121 : ch = ALT2; break;
case 122 : ch = ALT3; break;
case 123 : ch = ALT4; break;
case 124 : ch = ALT5; break;
case 125 : ch = ALT6; break;
case 126 : ch = ALT7; break;
case 127 : ch = ALT8; break;
case 128 : ch = ALT9; break;
case 129 : ch = ALT0; break;
case 130 : ch = ADASH; break;
case 131 : ch = AEQL; break;
case 30 : ch = ALTA; break;
case 48 : ch = ALTB; break;
case 46 : ch = ALTC; break;
case 32 : ch = ALTD; break;
case 18 : ch = ALTE; break;
case 33 : ch = ALTF; break;
case 34 : ch = ALTG; break;
case 35 : ch